package cn.tedu.boot32.mapper;

import cn.tedu.boot32.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    /*
        在数据库中,用户名只能够至多出现一次(人为保证),
        用对象接收数据,如果查询出了大于一条的记录,则会报错
     */
    @Select("select * from user where username = #{username}")
    User selectByUsername(String username);

    @Insert("insert into user values(null,#{username},#{password},#{nickname})")
    void insert(User user);
}
